<template>
  <div class="row">
    <div class="card" v-for="(user,index) in list" :key="user.id">
      <a href="https://github.com/xxxxxx" target="_blank">
        <img :src="user.avatar_url" style="width: 100px" />
      </a>
      <p class="card-text">{{user.login}}</p>
    </div>
  </div>
</template>

<script>
//引入函数
import { reqGitHub } from "@/api";
export default {
  name: "",
  data() {
    return {
      list: [],
    };
  },
  //组件挂载完毕
  mounted() {
    //接受兄弟组件的数据
    this.$bus.$on("send", async (userName) => {
      //这样书写的好处是什么？？？？
      try {
        let result = await reqGitHub(userName);
        this.list = result.items;
      } catch (error) {}
    });
  },
};
</script>

<style scoped>
</style>
